home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / gpmemacs.29 / gpmemacs-19.29.diff
Encoding:
Text File  |  1996-01-06  |  25.5 KB  |  867 lines

  1. ===================================================================
  2. RCS file: ./src/s/linux.h,v
  3. retrieving revision 1.1
  4. diff -b -B -C 3 -r1.1 ./src/s/linux.h
  5. *** ./src/s/linux.h    1995/12/30 18:56:50    1.1
  6. --- ./src/s/linux.h    1996/01/06 05:10:22
  7. ***************
  8. *** 200,205 ****
  9. --- 199,210 ----
  10.   #define LIB_GCC
  11.   #define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtn.o
  12.   #endif
  13. + #ifdef HAVE_LIBGPM
  14. + #define LIBS_GPM -lgpm
  15. + #else
  16. + #define LIBS_GPM
  17. + #endif /* HAVE_LIBGPM */
  18.   
  19.   /* Don't use -g in test compiles in configure.
  20.      This is so we will use the same shared libs for that linking
  21. ===================================================================
  22. RCS file: ./src/Makefile.in.in,v
  23. retrieving revision 1.1
  24. diff -b -B -C 3 -r1.1 ./src/Makefile.in.in
  25. *** ./src/Makefile.in.in    1995/12/30 19:06:07    1.1
  26. --- ./src/Makefile.in.in    1996/01/06 05:04:16
  27. ***************
  28. *** 471,481 ****
  29.   #define MSDOS_OBJ
  30.   #endif
  31.   
  32.   
  33.   /* lastfile must follow all files
  34.      whose initialized data areas should be dumped as pure by dump-emacs. */
  35.   obj=    dispnew.o frame.o scroll.o xdisp.o window.o \
  36. !     cm.o term.o $(XOBJ) \
  37.       emacs.o keyboard.o macros.o keymap.o sysdep.o \
  38.       buffer.o filelock.o insdel.o marker.o INTERVAL_OBJ \
  39.       minibuf.o fileio.o dired.o filemode.o \
  40. --- 471,488 ----
  41.   #define MSDOS_OBJ
  42.   #endif
  43.   
  44. + #ifdef HAVE_LIBGPM
  45. + #define GPM_OBJ gpmevent.o
  46. + #define GPM_SRC gpmevent.c
  47. + #else
  48. + #define GPM_OBJ
  49. + #define GPM_SRC
  50. + #endif
  51.   
  52.   /* lastfile must follow all files
  53.      whose initialized data areas should be dumped as pure by dump-emacs. */
  54.   obj=    dispnew.o frame.o scroll.o xdisp.o window.o \
  55. !     cm.o term.o $(XOBJ) GPM_OBJ \
  56.       emacs.o keyboard.o macros.o keymap.o sysdep.o \
  57.       buffer.o filelock.o insdel.o marker.o INTERVAL_OBJ \
  58.       minibuf.o fileio.o dired.o filemode.o \
  59. ***************
  60. *** 484,491 ****
  61.       eval.o floatfns.o fns.o print.o lread.o \
  62.       abbrev.o syntax.o UNEXEC mocklisp.o bytecode.o \
  63.       process.o callproc.o \
  64. !     region-cache.o \
  65. !     doprnt.o strftime.o MKTIME_OBJ GETLOADAVG_OBJ MSDOS_OBJ
  66.   
  67.   /* Object files used on some machine or other.
  68.      These go in the DOC file on all machines
  69. --- 491,498 ----
  70.       eval.o floatfns.o fns.o print.o lread.o \
  71.       abbrev.o syntax.o UNEXEC mocklisp.o bytecode.o \
  72.       process.o callproc.o \
  73. !     region-cache.o doprnt.o strftime.o \
  74. !     MKTIME_OBJ GETLOADAVG_OBJ MSDOS_OBJ 
  75.   
  76.   /* Object files used on some machine or other.
  77.      These go in the DOC file on all machines
  78. ***************
  79. *** 648,654 ****
  80.      Note that SunOS needs -lm to come before -lc; otherwise, you get
  81.      duplicated symbols.  If the standard libraries were compiled
  82.      with GCC, we might need gnulib again after them.  */
  83. ! LIBES = $(LIBX) LIBS_SYSTEM LIBS_MACHINE LIBS_TERMCAP \
  84.      LIBS_DEBUG $(GNULIB_VAR) LIB_MATH LIB_STANDARD $(GNULIB_VAR)
  85.   
  86.   /* Enable recompilation of certain other files depending on system type.  */
  87. --- 655,661 ----
  88.      Note that SunOS needs -lm to come before -lc; otherwise, you get
  89.      duplicated symbols.  If the standard libraries were compiled
  90.      with GCC, we might need gnulib again after them.  */
  91. ! LIBES = $(LIBX) LIBS_GPM LIBS_SYSTEM LIBS_MACHINE LIBS_TERMCAP \
  92.      LIBS_DEBUG $(GNULIB_VAR) LIB_MATH LIB_STANDARD $(GNULIB_VAR)
  93.   
  94.   /* Enable recompilation of certain other files depending on system type.  */
  95. ***************
  96. *** 846,851 ****
  97. --- 853,860 ----
  98.      it is so often changed in ways that do not require any recompilation
  99.      and so rarely changed in ways that do require any.  */
  100.   
  101. + gpmevent.o: gpmevent.c window.h blockinput.h termhooks.h termopts.h frame.h \
  102. +     sysselect.h syssignal.h
  103.   abbrev.o: abbrev.c buffer.h commands.h $(config_h) 
  104.   buffer.o: buffer.c buffer.h region-cache.h commands.h window.h \
  105.      INTERVAL_SRC blockinput.h $(config_h) 
  106. ===================================================================
  107. RCS file: ./src/config.h.in,v
  108. retrieving revision 1.1
  109. diff -b -B -C 3 -r1.1 ./src/config.h.in
  110. *** ./src/config.h.in    1995/12/30 20:02:12    1.1
  111. --- ./src/config.h.in    1996/01/06 05:04:17
  112. ***************
  113. *** 183,188 ****
  114. --- 183,195 ----
  115.   /* Define if `struct timeval' is declared by <sys/time.h>.  */
  116.   #undef HAVE_TIMEVAL
  117.   
  118. + /* Linux console mouse library. */
  119. + #undef HAVE_LIBGPM
  120. + #ifdef HAVE_LIBGPM
  121. + #define HAVE_MOUSE
  122. + #endif
  123.   /* If using GNU, then support inline function declarations. */
  124.   #ifdef __GNUC__
  125.   #define INLINE __inline__
  126. ===================================================================
  127. RCS file: ./src/keyboard.c,v
  128. retrieving revision 1.1
  129. diff -b -B -C 3 -r1.1 ./src/keyboard.c
  130. *** ./src/keyboard.c    1995/12/30 21:41:27    1.1
  131. --- ./src/keyboard.c    1996/01/06 05:04:19
  132. ***************
  133. *** 51,56 ****
  134. --- 51,58 ----
  135.   #include "syssignal.h"
  136.   #include "systty.h"
  137.   
  138. + extern int gpm_socket_used;            /* itz 12-31-95, from process.c */
  139.   /* This is to get the definitions of the XK_ symbols.  */
  140.   #ifdef HAVE_X_WINDOWS
  141.   #include "xterm.h"
  142. ***************
  143. *** 3090,3096 ****
  144.           pixel_to_glyph_coords (f, XINT (event->x), XINT (event->y),
  145.                      &column, &row, NULL, 1);
  146.   
  147. ! #ifndef USE_X_TOOLKIT
  148.           /* In the non-toolkit version, clicks on the menu bar
  149.              are ordinary button events in the event buffer.
  150.              Distinguish them, and invoke the menu.
  151. --- 3092,3098 ----
  152.           pixel_to_glyph_coords (f, XINT (event->x), XINT (event->y),
  153.                      &column, &row, NULL, 1);
  154.   
  155. ! #if (!defined(USE_X_TOOLKIT))
  156.           /* In the non-toolkit version, clicks on the menu bar
  157.              are ordinary button events in the event buffer.
  158.              Distinguish them, and invoke the menu.
  159. ***************
  160. *** 3098,3104 ****
  161.              (In the toolkit version, the toolkit handles the menu bar
  162.              and Emacs doesn't know about it until after the user
  163.              makes a selection.)  */
  164. !         if (row >= 0 && row < FRAME_MENU_BAR_LINES (f))
  165.             {
  166.           Lisp_Object items, item;
  167.           int hpos;
  168. --- 3100,3106 ----
  169.              (In the toolkit version, the toolkit handles the menu bar
  170.              and Emacs doesn't know about it until after the user
  171.              makes a selection.)  */
  172. !         if (!gpm_socket_used && row >= 0 && row < FRAME_MENU_BAR_LINES (f))
  173.             {
  174.           Lisp_Object items, item;
  175.           int hpos;
  176. ***************
  177. *** 6793,6799 ****
  178.   
  179.     kbd_buffer_frame_or_window
  180.       = Fmake_vector (make_number (KBD_BUFFER_SIZE), Qnil);
  181. !   if (!noninteractive && !read_socket_hook && NILP (Vwindow_system))
  182.       {
  183.         signal (SIGINT, interrupt_signal);
  184.   #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
  185. --- 6795,6802 ----
  186.   
  187.     kbd_buffer_frame_or_window
  188.       = Fmake_vector (make_number (KBD_BUFFER_SIZE), Qnil);
  189. !   if (!noninteractive && (!read_socket_hook || gpm_socket_used) &&
  190. !             NILP (Vwindow_system))
  191.       {
  192.         signal (SIGINT, interrupt_signal);
  193.   #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
  194. ===================================================================
  195. RCS file: ./src/sysdep.c,v
  196. retrieving revision 1.1
  197. diff -b -B -C 3 -r1.1 ./src/sysdep.c
  198. *** ./src/sysdep.c    1995/12/31 00:47:18    1.1
  199. --- ./src/sysdep.c    1996/01/06 05:04:20
  200. ***************
  201. *** 26,31 ****
  202. --- 25,32 ----
  203.   #include "blockinput.h"
  204.   #undef NULL
  205.   
  206. + extern int gpm_socket_used;            /* itz 12-31-95, from process.c */
  207.   #define min(x,y) ((x) > (y) ? (y) : (x))
  208.   
  209.   /* In this file, open, read and write refer to the system calls,
  210. ***************
  211. *** 242,248 ****
  212.   
  213.     /* Discarding input is not safe when the input could contain
  214.        replies from the X server.  So don't do it.  */
  215. !   if (read_socket_hook)
  216.       return;
  217.   
  218.   #ifdef VMS
  219. --- 243,249 ----
  220.   
  221.     /* Discarding input is not safe when the input could contain
  222.        replies from the X server.  So don't do it.  */
  223. !   if (read_socket_hook && !gpm_socket_used)
  224.       return;
  225.   
  226.   #ifdef VMS
  227. ***************
  228. *** 277,283 ****
  229.   stuff_char (c)
  230.        char c;
  231.   {
  232. !   if (read_socket_hook)
  233.       return;
  234.   
  235.   /* Should perhaps error if in batch mode */
  236. --- 278,284 ----
  237.   stuff_char (c)
  238.        char c;
  239.   {
  240. !   if (read_socket_hook && !gpm_socket_used)
  241.       return;
  242.   
  243.   /* Should perhaps error if in batch mode */
  244. ***************
  245. *** 1211,1224 ****
  246.   #endif /* not VMS */
  247.   
  248.   #ifdef BSD_PGRPS
  249. !   if (! read_socket_hook && EQ (Vwindow_system, Qnil))
  250.       narrow_foreground_group ();
  251.   #endif
  252.   
  253.   #ifdef HAVE_X_WINDOWS
  254.     /* Emacs' window system on MSDOG uses the `internal terminal' and therefore
  255.        needs the initialization code below.  */
  256. !   if (!read_socket_hook && EQ (Vwindow_system, Qnil))
  257.   #endif
  258.       {
  259.         EMACS_GET_TTY (input_fd, &old_tty);
  260. --- 1212,1225 ----
  261.   #endif /* not VMS */
  262.   
  263.   #ifdef BSD_PGRPS
  264. !   if ((!read_socket_hook || gpm_socket_used) && EQ (Vwindow_system, Qnil))
  265.       narrow_foreground_group ();
  266.   #endif
  267.   
  268.   #ifdef HAVE_X_WINDOWS
  269.     /* Emacs' window system on MSDOG uses the `internal terminal' and therefore
  270.        needs the initialization code below.  */
  271. !   if ((!read_socket_hook || gpm_socket_used) && EQ (Vwindow_system, Qnil))
  272.   #endif
  273.       {
  274.         EMACS_GET_TTY (input_fd, &old_tty);
  275. ***************
  276. *** 1458,1464 ****
  277.   #else
  278.     setbuf (stdout, _sobuf);
  279.   #endif
  280. !   if (! read_socket_hook && EQ (Vwindow_system, Qnil))
  281.       set_terminal_modes ();
  282.   
  283.     if (term_initted && no_redraw_on_reenter)
  284. --- 1459,1465 ----
  285.   #else
  286.     setbuf (stdout, _sobuf);
  287.   #endif
  288. !   if ((!read_socket_hook || gpm_socket_used) && EQ (Vwindow_system, Qnil))
  289.       set_terminal_modes ();
  290.   
  291.     if (term_initted && no_redraw_on_reenter)
  292. ***************
  293. *** 1600,1606 ****
  294.   #ifdef HAVE_X_WINDOWS
  295.     /* Emacs' window system on MSDOG uses the `internal terminal' and therefore
  296.        needs the clean-up code below.  */
  297. !   if (read_socket_hook || !EQ (Vwindow_system, Qnil))
  298.       return;
  299.   #endif
  300.     cursor_to (FRAME_HEIGHT (selected_frame) - 1, 0);
  301. --- 1601,1607 ----
  302.   #ifdef HAVE_X_WINDOWS
  303.     /* Emacs' window system on MSDOG uses the `internal terminal' and therefore
  304.        needs the clean-up code below.  */
  305. !   if ((read_socket_hook && !gpm_socket_used) || !EQ (Vwindow_system, Qnil))
  306.       return;
  307.   #endif
  308.     cursor_to (FRAME_HEIGHT (selected_frame) - 1, 0);
  309. ===================================================================
  310. RCS file: ./src/term.c,v
  311. retrieving revision 1.1
  312. diff -b -B -C 3 -r1.1 ./src/term.c
  313. *** ./src/term.c    1995/12/31 00:53:00    1.1
  314. --- ./src/term.c    1996/01/06 05:04:21
  315. ***************
  316. *** 42,47 ****
  317. --- 42,49 ----
  318.   #define OUTPUT_IF(a) { if (a) tputs (a, FRAME_HEIGHT (selected_frame) - curY, cmputc); }
  319.   #define OUTPUT1_IF(a) { if (a) tputs (a, 1, cmputc); }
  320.   
  321. + int gpm_socket_used = 0;                /* itz 12-31-95 */
  322.   /* Terminal characteristics that higher levels want to look at.
  323.      These are all extern'd in termchar.h */
  324.   
  325. ===================================================================
  326. RCS file: ./src/gpmevent.c,v
  327. retrieving revision 1.1
  328. diff -b -B -C 3 -r1.1 ./src/gpmevent.c
  329. *** ./src/gpmevent.c    1995/12/31 01:57:49    1.1
  330. --- ./src/gpmevent.c    1996/01/06 05:04:22
  331. ***************
  332. *** 1,3 ****
  333. --- 1,413 ----
  334.   /* gpmevent.h */
  335.   /* Linux-specific hooks to handle events from the console mouse library */
  336.   
  337. + #include <sys/time.h>
  338. + #include <sys/types.h>
  339. + #include <unistd.h>
  340. + #include <stdio.h> 
  341. + #include <values.h> 
  342. + #include <gpm.h> 
  343. + #include <errno.h> 
  344. + #include <signal.h> 
  345. + #include <config.h>
  346. + #include "lisp.h" 
  347. + #include "window.h" 
  348. + #include "blockinput.h"                    /* itz 12-31-95 do we really need this? */
  349. + #include "termhooks.h" 
  350. + #include "termopts.h" 
  351. + #include "frame.h" 
  352. + #include "sysselect.h" 
  353. + #include "syssignal.h" 
  354. + /* Because of the way the socket hook is called in read_input_waiting,
  355. +      we give up without a real select(). While we are at it, don't
  356. +      support losing non-posix systems and non-ansi compilers. */
  357. + #if (!defined(HAVE_SELECT) || !defined(_POSIX_VERSION) || !defined(__STDC__))
  358. + you lose
  359. + #endif
  360. + #if (!defined(__linux__))                /* possible under xterm */
  361. + #define KG_SHIFT    0
  362. + #define KG_CTRL        2
  363. + #define KG_ALT        3
  364. + #else
  365. + #include <linux/keyboard.h> 
  366. + #endif
  367. + #define max(x,y)    ((x) < (y) ? (y) : (x))
  368. + #define GPM_CLICK (GPM_DOWN|GPM_UP)
  369. + /* This is a fake, just to distinguish single and multiple clicks */
  370. + static unsigned long gpm_timestamp = 1;
  371. + /* somebody else may have already hooked read_socket_hook. Be nice and
  372. +      chain to them */
  373. + static int (*saved_read_socket_hook)();
  374. + /* For communication between the gpm handler and the socket hook. */
  375. + static Gpm_Event gpm_event;
  376. + /* Set this when we start a drag in the rightmost column of a window,
  377. +      so that we know to provide scroll bar behaviour. */
  378. + static int scroll_barring;
  379. + /* Pass this to Gpm_Getc. Need to be careful with stdio buffering */
  380. + FILE* gpm_file;
  381. + /* gpm handling function. this is kind of a joke, because we only want
  382. +      raw mouse events anyway and don't translate them into keypresses;
  383. +      however, the code in keyboard.c that calls us assumes we are going
  384. +      to process both mouse and keyboard input, and so we have to call
  385. +      Gpm_Getchar() not select() and Gpm_GetEvent(). Also we want to
  386. +      support gpmlib's xterm mode, at least in theory. */
  387. + static int gpm_mouse_handler(Gpm_Event *event, void *clientdata)
  388. + {
  389. +     gpm_event = *event;
  390. +     return  1;
  391. + }
  392. + /* Do this as efficiently as possible. */
  393. + static Lisp_Object gpm_get_window_and_coordinates (int* w_x, int* w_y,
  394. +                                                                                                      int* part)
  395. + {
  396. +     Lisp_Object w_first, w_temp;
  397. +     w_first = FRAME_SELECTED_WINDOW(selected_frame);            
  398. +     w_temp = Fnext_window (w_first, Qt, Qlambda);
  399. +     *part = coordinates_in_window (XWINDOW (w_temp), w_x, w_y);
  400. +     while (!*part && !EQ(w_temp, w_first)) {
  401. +         w_temp = Fnext_window (w_temp, Qt, Qlambda);
  402. +         *part = coordinates_in_window (XWINDOW (w_temp), w_x, w_y);
  403. +     } /*while*/
  404. +     return w_temp;
  405. + }
  406. + static void gpm_get_mouse_pos (FRAME_PTR* f, int insist,
  407. +                                                              Lisp_Object* bar_window,
  408. +                                                              enum scroll_bar_part *part, 
  409. +                                                              Lisp_Object* x, Lisp_Object* y,
  410. +                                                              unsigned long* time) 
  411. + {
  412. +   *f = selected_frame;
  413. +     *time = gpm_timestamp;
  414. +     if (!scroll_barring) {
  415. +         *bar_window = Qnil;                        
  416. +         XSETINT(*x, gpm_event.x);
  417. +         XSETINT(*y, gpm_event.y);
  418. +     }  else {
  419. +         int party_dummy;
  420. +         int w_x = gpm_event.x, w_y = gpm_event.y;
  421. +         *bar_window = gpm_get_window_and_coordinates (&w_x, &w_y, &party_dummy);
  422. +         XSETINT(*x, w_y);
  423. +         XSETINT(*y, window_internal_height (XWINDOW(*bar_window)));
  424. +         *part = scroll_bar_handle;
  425. +     } /*if*/
  426. +   mouse_moved = 0;
  427. + }
  428. + /* These are trivial, just as under MSDOG (lifted from there) */
  429. + void pixel_to_glyph_coords (FRAME_PTR f, int pix_x, int pix_y, int* x,
  430. +                                                         int* y, void* bounds, int noclip)
  431. + {
  432. +   if (bounds) abort ();
  433. +   /* Ignore clipping.  */
  434. +   *x = pix_x;
  435. +   *y = pix_y;
  436. +     /* argsused f */
  437. +     /* argsused noclip */
  438. + }
  439. + void glyph_to_pixel_coords (FRAME_PTR f, int x, int y, int* pix_x,
  440. +                                                         int* pix_y)
  441. + {
  442. +   *pix_x = x;
  443. +   *pix_y = y;
  444. + }
  445. + /* main gpm hook. Mimic XTread_socket but i hope it will be much
  446. +      simpler than that. The waitp/expect arguments to XTread_Socket are
  447. +      ignored -- it never waits */
  448. + static int gpm_read_socket (int sd, struct input_event buf [], int bufsize,
  449. +                                          int waitp, int expected)
  450. + {
  451. +     int nread = 0;
  452. +     int c;
  453. +     if (sd != fileno(gpm_file)) {    /* oops, somebody changed the input */
  454. +         abort ();                                        /* descriptor on us. that ain't */
  455. +     } /*if*/                                        /* going to work */ 
  456. +     if (saved_read_socket_hook) {
  457. +         nread = saved_read_socket_hook (sd, buf, bufsize, waitp,
  458. +                                                                         expected);
  459. +         if (nread < 0) {
  460. +             return  nread;
  461. +         } /*if*/
  462. +     } /*if*/
  463. +   if (BLOCK_INPUT) {
  464. +         interrupt_input_pending = 1;
  465. +         (void) UNBLOCK_INPUT;
  466. +         return -1;
  467. +     } /*if*/
  468. +     while (nread < bufsize) {
  469. +         if (nread >= expected || mouse_moved) {                        
  470. +             fd_set readfds;                
  471. +             struct timeval timeout;
  472. +             FD_ZERO(&readfds);
  473. +             FD_SET(sd, &readfds);
  474. +             if (gpm_fd >= 0) {
  475. +                 FD_SET(gpm_fd, &readfds);
  476. +             } /*if*/
  477. +             timeout.tv_sec = timeout.tv_usec = 0;
  478. +             if (!select (max(gpm_fd, sd)+1, &readfds, 0, 0, &timeout)) {
  479. +                 break;                                    /* out of while */
  480. +             } /*if*/
  481. +         } /*if*/
  482. +         c = Gpm_Getc (gpm_file);
  483. +         if (!gpm_flag) {                        /* connection has gone */
  484. +             gpm_hflag = 0;                        /* libgpm doesn't do this */
  485. +         } /*if*/
  486. +         if (gpm_hflag) {                        /* it is a click */
  487. +             extern Lisp_Object Vdouble_click_time;
  488. +             int i, button = -1;
  489. +             int part;
  490. +             int w_x, w_y;
  491. +             Lisp_Object w_temp;
  492. +             static unsigned char gpm_buttons [] =
  493. +                     {GPM_B_LEFT, GPM_B_MIDDLE, GPM_B_RIGHT};
  494. +             static unsigned char gpm_modifiers [] =
  495. +                     {1<<KG_SHIFT, 1<<KG_CTRL, 1<<KG_ALT};
  496. +             static int emacs_modifiers [] =
  497. +                     {shift_modifier, ctrl_modifier, meta_modifier};
  498. +             int type = GPM_BARE_EVENTS(gpm_event.type);
  499. +             /* For now, fit all events to the visible screen */
  500. +             Gpm_FitEvent (&gpm_event);
  501. +             for (i = 0; i < 3; ++i) {
  502. +                 if (gpm_event.buttons == gpm_buttons[i]) {
  503. +                     button = i;
  504. +                 } /*if*/
  505. +             } /*for*/
  506. +             if (button == -1) {
  507. +                 gpm_timestamp += XINT(Vdouble_click_time);
  508. +                 continue;                                    /* don't support cords */
  509. +             } /*if*/
  510. +             /* First, drags and moves are not reported directly to caller,
  511. +                  but polled for by checking mouse_moved */
  512. +             if (!(type & GPM_CLICK)) {
  513. +                 mouse_moved = 1;
  514. +                 gpm_timestamp += 1;
  515. +                 continue;                                /* back to while */
  516. +             } else if (scroll_barring || type == GPM_DOWN)  {
  517. +                 /* iff this is a click-down in the scroll-bar area, initiate
  518. +                  scrollbar mode. */
  519. +                 w_x = gpm_event.x; w_y = gpm_event.y;
  520. +                 w_temp = gpm_get_window_and_coordinates (&w_x, &w_y, &part);
  521. +                 /* strange, mouse click in no window */
  522. +                 if (!part) {
  523. +                     abort ();
  524. +                 } /*if*/
  525. +                 if (part == 1 &&
  526. +                         w_x+1 == window_internal_width (XWINDOW(w_temp))) {
  527. +                     scroll_barring = 1;
  528. +                 } /*if*/
  529. +             }
  530. +             buf[nread].modifiers = 0;
  531. +             switch (type) {
  532. +             case GPM_DOWN:
  533. +                 buf[nread].modifiers |= down_modifier;
  534. +                 gpm_timestamp += (gpm_event.clicks != 0 ? 1 : XINT(Vdouble_click_time));
  535. +                 if (gpm_fd >= 0) {
  536. +                     gpm_visiblepointer = 1;
  537. +                 } /*if*/
  538. +                 break; 
  539. +             case GPM_UP:
  540. +                 buf[nread].modifiers |= up_modifier;
  541. +                 gpm_timestamp += 1;
  542. +                 gpm_visiblepointer = 0;
  543. +                 break;
  544. +             default:
  545. +                 abort ();                                        /* can't happen */
  546. +             } /*switch*/
  547. +             for (i = 0; i < 3; ++i) {
  548. +                 if (gpm_event.modifiers & gpm_modifiers[i]) {
  549. +                     buf[nread].modifiers |= emacs_modifiers[i];
  550. +                 } /*if*/
  551. +             } /*for*/
  552. +             buf[nread].code = button;
  553. +             buf[nread].timestamp = gpm_timestamp;                
  554. +             if (!scroll_barring) {
  555. +                 buf[nread].kind = mouse_click;
  556. +                 buf[nread].x = gpm_event.x;
  557. +                 buf[nread].y = gpm_event.y;
  558. +                 XSETFRAME(buf[nread].frame_or_window, selected_frame);
  559. +             }  else {
  560. +                 buf[nread].kind = scroll_bar_click;
  561. +                 buf[nread].part = scroll_bar_handle; /* this is ignored by lisp */
  562. +                 buf[nread].x = w_y;
  563. +                 buf [nread].y = window_internal_height (XWINDOW(w_temp));
  564. +                 buf[nread].frame_or_window = w_temp;
  565. +                 if (type == GPM_UP) {
  566. +                     scroll_barring = 0;
  567. +                 } /*if*/
  568. +             } /*if*/
  569. +         }  else {                                        /* it is a keypress */
  570. +             if (feof(gpm_file)) {
  571. +                 break;                                    /* should get SIGHUP */
  572. +             }  else  if (ferror(gpm_file)) {
  573. +                 clearerr (gpm_file);
  574. +                 if (errno == EAGAIN) {
  575. +                     continue;                            /* back to while */
  576. +                 } /*if*/
  577. +                 nread = -1;
  578. +                 break;                                    /* something awful */
  579. +             } /*if*/
  580. +             buf[nread].kind = ascii_keystroke;
  581. +             buf[nread].modifiers = 0;
  582. +             if (meta_key == 1 && (c & 0x80)) {
  583. +                 buf[nread].modifiers = meta_modifier;
  584. +             } /*if*/
  585. +             if (meta_key != 2) {
  586. +                 c &= ~0x80;
  587. +             } /*if*/
  588. +             buf[nread].code = c;
  589. +             XSETFRAME(buf[nread].frame_or_window, selected_frame);
  590. +         } /*if*/
  591. +         /* All done! */
  592. +         nread += 1;
  593. +     } /*while*/
  594. +     (void) UNBLOCK_INPUT;
  595. +     return nread;
  596. + }
  597. + #if (defined(SIGTSTP)) 
  598. + /* Old SIGTSTP handler. */
  599. + static signal_handler_t saved_suspend_hook;
  600. + static RETSIGTYPE gpm_suspend_hook ()
  601. + {
  602. +     Gpm_Connect gpm_connect;
  603. +     SIGMASKTYPE smask =sigmask (SIGTSTP);
  604. +     int success;
  605. +     /* Open a completely transparent gpm connection */
  606. +     gpm_connect.eventMask = 0;
  607. +     gpm_connect.defaultMask = ~0;
  608. +     gpm_connect.minMod = ~0;
  609. +     gpm_connect.maxMod = 0;
  610. +     /* cannot do this under xterm, tough */
  611. +     success = (Gpm_Open (&gpm_connect, 0) >= 0);
  612. +     /* take the default action, whatever it is (probably a stop :) */
  613. +     sigunblock (smask);
  614. +     signal (SIGTSTP, saved_suspend_hook);
  615. +     kill (getpid (), SIGTSTP);
  616. +     /* in bardo here */
  617. +     /* Reincarnation. Prepare for another death early. */
  618. +     signal (SIGTSTP, gpm_suspend_hook);
  619. +     /* Pop the gpm stack by closing the useless connection */
  620. +     /* but do it only when we know we opened one.. */
  621. +     if (success) {
  622. +         Gpm_Close ();
  623. +     } /*if*/
  624. + }
  625. + #endif
  626. + /* do the initialization stuff. This is called from init_process,
  627. +      because it has to set the socket bit in input_wait_mask. */
  628. + int init_gpm ()
  629. + {
  630. +     Gpm_Connect gpm_connect;
  631. +     int had_keyboard_input;
  632. +     extern int input_fd;
  633. +     fd_set test_input_fd;
  634. +     /* first, if we are under X graphics, nothing doing. */
  635. +     if (noninteractive || !NILP(Vwindow_system)) {
  636. +         return 0;
  637. +     } /*if*/
  638. +     gpm_file = fdopen(input_fd,"r");
  639. +     if (!gpm_file) {
  640. +         return 0;
  641. +     } /*if*/
  642. +     gpm_handler = gpm_mouse_handler;
  643. +     gpm_zerobased = 1;
  644. +     
  645. +     /* Try to open a gpm connection. */
  646. +     gpm_connect.eventMask = (GPM_DOWN|GPM_UP|GPM_DRAG);/* this may eventually be overkill, but right now we need it for testing */
  647. +     gpm_connect.defaultMask = GPM_MOVE; /* steal drags to prevent highlighting */
  648. +     gpm_connect.minMod = 0;
  649. +     gpm_connect.maxMod = ((1<<KG_SHIFT)|(1<<KG_ALT)|(1<<KG_CTRL));
  650. +     if (Gpm_Open (&gpm_connect, 0) == -1) {
  651. +         return 0;
  652. +     } /*if*/
  653. +     /* OK, if we got here everything is peachy. setup the event hook and
  654. +      other things */
  655. +     saved_read_socket_hook = read_socket_hook;
  656. +     read_socket_hook = gpm_read_socket;
  657. +     mouse_position_hook = gpm_get_mouse_pos;
  658. +     
  659. +     FD_ZERO(&test_input_fd);
  660. +     FD_SET(input_fd, &test_input_fd);
  661. +     had_keyboard_input = keyboard_bit_set (&test_input_fd);
  662. +     if (gpm_fd >= 0) {                        /* can be -2 for xterm */
  663. +         add_keyboard_wait_descriptor (gpm_fd);
  664. +     } /*if*/
  665. +     if (had_keyboard_input) {
  666. +         add_keyboard_wait_descriptor (input_fd);
  667. +     } /*if*/
  668. + #if (defined(SIGTSTP)) 
  669. +     /* Install suspend hook */
  670. +     if ((saved_suspend_hook = signal (SIGTSTP, SIG_IGN)) != SIG_IGN) {
  671. +         signal (SIGTSTP, gpm_suspend_hook);
  672. +     } /*if*/
  673. + #endif
  674. +     return  1;
  675. + }
  676. + /* Called from redisplay, hopefully after all terminal refresh. */
  677. + void gpm_redisplay_pointer ()
  678. + {
  679. +     if (gpm_fd >= 0 && gpm_visiblepointer) {
  680. +         GPM_DRAWPOINTER (&gpm_event);
  681. +     } /*if*/
  682. + }
  683. + /* Local Variables: */
  684. + /* mode:C */
  685. + /* tab-width:2 */
  686. + /* End: */
  687. ===================================================================
  688. RCS file: ./src/process.c,v
  689. retrieving revision 1.1
  690. diff -b -B -C 3 -r1.1 ./src/process.c
  691. *** ./src/process.c    1996/01/01 06:13:48    1.1
  692. --- ./src/process.c    1996/01/06 05:04:23
  693. ***************
  694. *** 3538,3544 ****
  695.   {
  696.     int fd;
  697.   
  698. !   for (fd = 0; fd < max_keyboard_desc; fd++)
  699.       if (FD_ISSET (fd, mask) && FD_ISSET (fd, &input_wait_mask)
  700.       && !FD_ISSET (fd, &non_keyboard_wait_mask))
  701.         return 1;
  702. --- 3538,3545 ----
  703.   {
  704.     int fd;
  705.   
  706. !     /* itz 01-01-96  A NASTY CRITTER! This was `<' */
  707. !   for (fd = 0; fd <= max_keyboard_desc; fd++)
  708.       if (FD_ISSET (fd, mask) && FD_ISSET (fd, &input_wait_mask)
  709.       && !FD_ISSET (fd, &non_keyboard_wait_mask))
  710.         return 1;
  711. ***************
  712. *** 3546,3551 ****
  713. --- 3547,3555 ----
  714.     return 0;
  715.   }
  716.   
  717. + extern int gpm_socket_used ;                /* itz 12-31-95 */
  718.   init_process ()
  719.   {
  720.     register int i;
  721. ***************
  722. *** 3563,3568 ****
  723. --- 3567,3579 ----
  724.   
  725.     FD_SET (0, &input_wait_mask);
  726.   
  727. + #if (defined(HAVE_LIBGPM))
  728. +     {
  729. +         extern int init_gpm();
  730. +         gpm_socket_used = init_gpm();
  731. +     }
  732. + #endif
  733.     Vprocess_alist = Qnil;
  734.     for (i = 0; i < MAXDESC; i++)
  735.       {
  736. ===================================================================
  737. RCS file: ./src/xdisp.c,v
  738. retrieving revision 1.1
  739. diff -b -B -C 3 -r1.1 ./src/xdisp.c
  740. *** ./src/xdisp.c    1996/01/04 07:43:30    1.1
  741. --- ./src/xdisp.c    1996/01/06 05:04:25
  742. ***************
  743. *** 1129,1134 ****
  744. --- 1129,1138 ----
  745.         windows_or_buffers_changed = 0;
  746.       }
  747.   
  748. + #if (defined(HAVE_LIBGPM))
  749. +         gpm_redisplay_pointer();
  750. + #endif
  751. +     
  752.     /* Start SIGIO interrupts coming again.
  753.        Having them off during the code above
  754.        makes it less likely one will discard output,
  755. ===================================================================
  756. RCS file: ./src/window.c,v
  757. retrieving revision 1.1
  758. diff -b -B -C 3 -r1.1 ./src/window.c
  759. *** ./src/window.c    1996/01/05 07:48:56    1.1
  760. --- ./src/window.c    1996/01/06 05:04:27
  761. ***************
  762. *** 343,349 ****
  763.      if it is on the window's modeline, return 2;
  764.      if it is on the border between the window and its right sibling,
  765.         return 3.  */
  766. ! static int
  767.   coordinates_in_window (w, x, y)
  768.        register struct window *w;
  769.        register int *x, *y;
  770. --- 343,349 ----
  771.      if it is on the window's modeline, return 2;
  772.      if it is on the border between the window and its right sibling,
  773.         return 3.  */
  774. ! int
  775.   coordinates_in_window (w, x, y)
  776.        register struct window *w;
  777.        register int *x, *y;
  778. ===================================================================
  779. RCS file: ./configure.in,v
  780. retrieving revision 1.1
  781. diff -b -B -C 3 -r1.1 ./configure.in
  782. *** ./configure.in    1995/12/30 18:17:53    1.1
  783. --- ./configure.in    1996/01/06 05:04:27
  784. ***************
  785. *** 1234,1239 ****
  786. --- 1234,1244 ----
  787.     AC_DEFINE(HAVE_AIX_SMT_EXP)
  788.   fi
  789.   
  790. + # itz 12-30-95: check for libgpm on linux
  791. + if test "${opsys}" = "linux"; then
  792. +     AC_CHECK_LIB(gpm, Gpm_Open)
  793. + fi
  794.   # Set up the CFLAGS for real compilation, so we can substitute it.
  795.   CFLAGS="$REAL_CFLAGS"
  796.   
  797.